package com.boxin.ims.modules.wechat.busi;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boxin.ims.modules.wechat.entity.BusinessNewsReply;
import com.boxin.ims.modules.wechat.entity.NewsReply;
import com.boxin.ims.modules.wechat.entity.UserBusiness;
import com.boxin.ims.modules.wechat.entity.UserDefine;
import com.boxin.ims.modules.wechat.service.BusinessNewsReplyService;
import com.boxin.ims.modules.wechat.utils.DataUtils;
import com.boxin.ims.modules.wechat.utils.WechatUtils;
/**
 * @author Jakemanse
 * @date 2013-10-23
 * @function <p>在线报名 或 预定，预约</p>
 */
@Service
public class SignupOrBookProcessor extends BusinessProcessor{
	
	
	@Autowired
	private BusinessNewsReplyService businessNewsReplyService;

	public SignupOrBookProcessor() {
		super();
	}
	
	
	@Override
	public ProcessMessage process() {
		
		String reply = "<a href=\"http://weixin.zhaotang.net/zt/f/mobsite/signup/reg/"+user.getId() +"\">狂点我进入网页</a>";
		//回复
		writeToUser(reply);
		
//		UserDefine userDefine = WechatUtils.getUserDefineByUserId(user.getId());
//		
//		String title = "在线报名";
//		if(userDefine != null && StringUtils.isNotEmpty(userDefine.getSignupTitle())){
//			title = userDefine.getSignupTitle();
//		}
//		
//		String desc = "点击图片进入签到送积分页面。";
//		if(userDefine != null && StringUtils.isNotEmpty(userDefine.getSignupDesc())){
//			desc = userDefine.getSignupDesc();
//		}
//		
//		String picName = "signupscore.jpg";
//		
//		
//		
//		if(userDefine!=null && StringUtils.isNotEmpty(userDefine.getSignupPic())){
//			picName = userDefine.getSignupPic();
//		}
//		
//		
//		UserBusiness userBusiness = 	WechatUtils.getUserBusinessByKeyWords(user.getId(),"在线报名");
//		String picUrl = "http://weixin.zhaotang.net/zt/userfiles/images/"+picName+"?t="+System.currentTimeMillis();
//		String url = "http://weixin.zhaotang.net/zt/f/wechat/tosignup/"+user.getId() +"?oid="+openId;
//		
//		
//		if(userDefine!=null){
//			List<BusinessNewsReply>	businessNewsList = businessNewsReplyService.findByTypeSourceId("business", user.getId() , userBusiness.getId()+"");
//			if(businessNewsList != null && !businessNewsList.isEmpty()){	//多图文回复
//				/**
//				 * 多图文回复
//				 */	
//				BusinessNewsReply bnr = new BusinessNewsReply();
//				bnr.setDescription(desc);
//				bnr.setTitle(title);
//				bnr.setPicUrl(picUrl);
//				bnr.setUrl(url);
//				businessNewsList.add(0, bnr);
//				
//				List<NewsReply> newsReplies = DataUtils.convertToNewsReplyList(businessNewsList);
//				if(newsReplies!=null  && !newsReplies.isEmpty()){
//					for(NewsReply newsReply : newsReplies){
//						String descTemp = newsReply.getDescription();
//						descTemp = descTemp.replaceAll("%分值%", userDefine.getSignScore()+"");
//						newsReply.setDescription(descTemp);
//					}
//					
//				}
//				
//				this.writeMultiImagesToUser(newsReplies);
//				return null;
//			}
//		}
		
		return null;
	}
	
	
	

	@Override
	public boolean isNeedBeMember() {
		// TODO Auto-generated method stub
		return false;
	}

}
